<template>
  <div>
    <!-- 自定义内容 -->
    <edu-editor v-if="dataType == 0" :key="field" :value.sync="current_value" :args="{}" />
    <!-- 链接 -->
    <edu-input v-else-if="dataType == 1" :value.sync="current_value" :args="{ placeholder: '请输入完整的链接地址' }" />
    <!-- 协议 -->
    <agreement v-else-if="dataType == 2" :value.sync="current_value" :title="txt_value" />
    <div v-else>暂不支持该类型</div>
  </div>
</template>

<script>
import EduEditor from '@public/form/editor.vue';
import EduInput from '@public/form/input';
import Agreement from '@/pages/content/agreement/choose';

export default {
  components: {
    EduEditor,
    EduInput,
    Agreement
  },
  props: {
    value: {
      type: Number,
      default: 0
    },
    field: {
      type: String,
      required: true,
      default: ''
    },
    formDatas: {
      type: Object,
      required: true,
      default: _ => {
        return {};
      }
    }
  },
  data() {
    return {
      current_value: this.value,
      txt_value: this.formDatas.content_text
    };
  },
  computed: {
    dataType() {
      return this.formDatas.data_type;
    }
  },
  watch: {
    current_value(value) {
      this.$emit('update:value', value);
    },
    txt_value(value) {
      this.$emit('update:value', value);
    },
    dataType(type) {
      if (type == 0 || type == 1) {
        this.current_value = '';
      } else {
        this.current_value = 0;
      }
    }
  }
};
</script>
